// pages/discover/teaer/index.js
import axios,{baseUrl} from '../../../utils/axios';
Component({

  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    list:[],
    enable: false,
    loadingProps: {
      size: '50rpx',
    },
    rowCol1: [{ width: '100%', height: '342rpx', borderRadius: '24rpx' }],
    rowCol2: [[{ width: '327rpx' }], [{ width: '200rpx' }], [{ size: '327rpx', borderRadius: '24rpx' }]],
    scrollTop: 0,
  },

  /**
   * 组件的方法列表
   */
  methods: {
    async onRefresh() {
      this.setData({ enable: true });
      await this.queryTeaerList()
      this.setData({ enable: false });
    },
    onScroll(e) {
      const { scrollTop } = e.detail;
      this.setData({ scrollTop });
    },
    toDetail(e){
      const {u} = e.currentTarget.dataset
      wx.navigateTo({
        url: './traerDetail/index?id='+u.ID,
      })
    },
    async queryTeaerList(){
      await axios.get("/app/queryTeaerList",{
        role:0,
        status:2
      }).then(res=>{
        this.setData({
          list:res.data.map((item)=>{
            item.avatraUrl = baseUrl+item.avatar[0].url;
            item.bgImg = baseUrl+ (item.avatar[1] || item.avatar[0]).url;
            item.workText = "";
            if(item.workStatus == 1){
              item.workText = "工作中"
            }
            return item;
          })
        })
      })
      return 1
    }
  },
  lifetimes:{
    ready(){
      this.setData({ enable: true });
    setTimeout(() => {
      this.setData({ enable: false });
    }, 1000);
      this.queryTeaerList()
    }
  }
})